<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="keyword"  content="">
    <link rel="shortcut icon" href="/img/ironman-draw.png">
    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>
    <title>
        
          Spring Boot 内置工具类总结  - 吃素的左撇子 | Blog
        
    </title>

    <link rel="canonical" href="http://www.wangxiaohuan.com/Git命令/2019-03-10/">

    <!-- Bootstrap Core CSS -->
    
<link rel="stylesheet" href="/css/bootstrap.min.css">


    <!-- Custom CSS --> 
    
<link rel="stylesheet" href="/css/beantech.min.css">


    
<link rel="stylesheet" href="/css/donate.css">

    
    <!-- Pygments Highlight CSS -->
    
<link rel="stylesheet" href="/css/highlight.css">


    
<link rel="stylesheet" href="/css/widget.css">


    
<link rel="stylesheet" href="/css/rocket.css">


    
<link rel="stylesheet" href="/css/signature.css">


    
<link rel="stylesheet" href="/css/toc.css">


    <!-- Custom Fonts -->
    <!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> -->
    <!-- Hux change font-awesome CDN to qiniu -->
    <link href="https://cdn.staticfile.org/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">


    <!-- Hux Delete, sad but pending in China
    <link href='http://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/
    css'>
    -->


    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- ga & ba script hoook -->
    <script></script>
<meta name="generator" content="Hexo 4.2.1"></head>


<!-- hack iOS CSS :active style -->
<body ontouchstart="">
	<!-- Modified by Yu-Hsuan Yen -->
<!-- Post Header -->
<style type="text/css">
    header.intro-header{
        
            background-image: url('http://image.wangxiaohuan.com/blog/image/202201271525311.png')
            /*post*/
        
    }
    
</style>

<header class="intro-header" >
    <!-- Signature -->
    <div id="signature">
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                
                    <div class="post-heading">
                        <div class="tags">
                            
                              <a class="tag" href="/tags/#Git" title="Git">Git</a>
                            
                        </div>
                        <h1>Spring Boot 内置工具类总结 </h1>
                        <h2 class="subheading"></h2>
                        <span class="meta">
                            Posted by 吃素的左撇子 on
                            2019-03-10
                        </span>
                    </div>
                


                </div>
            </div>
        </div>
    </div>
</header>

	
    <!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header page-scroll">
            <button type="button" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/">吃素的左撇子</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <!-- Known Issue, found by Hux:
            <nav>'s height woule be hold on by its content.
            so, when navbar scale out, the <nav> will cover tags.
            also mask any touch event of tags, unfortunately.
        -->
        <div id="huxblog_navbar">
            <div class="navbar-collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="/">Home</a>
                    </li>

                    

                        
                    

                        
                        <li>
                            <a href="/about/">About Me</a>
                        </li>
                        
                    

                        
                        <li>
                            <a href="/archive/">Archive</a>
                        </li>
                        
                    

                        
                        <li>
                            <a href="/tags/">Tags</a>
                        </li>
                        
                    
                    
                </ul>
            </div>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
</nav>
<script>
    // Drop Bootstarp low-performance Navbar
    // Use customize navbar with high-quality material design animation
    // in high-perf jank-free CSS3 implementation
    var $body   = document.body;
    var $toggle = document.querySelector('.navbar-toggle');
    var $navbar = document.querySelector('#huxblog_navbar');
    var $collapse = document.querySelector('.navbar-collapse');

    $toggle.addEventListener('click', handleMagic)
    function handleMagic(e){
        if ($navbar.className.indexOf('in') > 0) {
        // CLOSE
            $navbar.className = " ";
            // wait until animation end.
            setTimeout(function(){
                // prevent frequently toggle
                if($navbar.className.indexOf('in') < 0) {
                    $collapse.style.height = "0px"
                }
            },400)
        }else{
        // OPEN
            $collapse.style.height = "auto"
            $navbar.className += " in";
        }
    }
</script>


    <!-- Main Content -->
    <!-- Modify by Yu-Hsuan Yen -->

<!-- Post Content -->
<article>
    <div class="container">
        <div class="row">

            <!-- Post Container -->
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                post-container">

                <h2 id="断言">断言</h2>
<ol>
<li>断言是一个逻辑判断，用于检查不应该发生的情况</li>
<li>Assert 关键字在 JDK1.4 中引入，可通过 JVM 参数<code>-enableassertions</code>开启</li>
<li>SpringBoot 中提供了 Assert 断言工具类，通常用于数据合法性检查</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 要求参数 object 必须为非空（Not Null），否则抛出异常，不予放行</span><br><span class="line">&#x2F;&#x2F; 参数 message 参数用于定制异常信息。</span><br><span class="line">void notNull(Object object, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数必须空（Null），否则抛出异常，不予『放行』。</span><br><span class="line">&#x2F;&#x2F; 和 notNull() 方法断言规则相反</span><br><span class="line">void isNull(Object object, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数必须为真（True），否则抛出异常，不予『放行』。</span><br><span class="line">void isTrue(boolean expression, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数（List&#x2F;Set）必须非空（Not Empty），否则抛出异常，不予放行</span><br><span class="line">void notEmpty(Collection collection, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数（String）必须有长度（即，Not Empty），否则抛出异常，不予放行</span><br><span class="line">void hasLength(String text, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数（String）必须有内容（即，Not Blank），否则抛出异常，不予放行</span><br><span class="line">void hasText(String text, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数是指定类型的实例，否则抛出异常，不予放行</span><br><span class="line">void isInstanceOf(Class type, Object obj, String message)</span><br><span class="line">&#x2F;&#x2F; 要求参数 &#96;subType&#96; 必须是参数 superType 的子类或实现类，否则抛出异常，不予放行</span><br><span class="line">void isAssignable(Class superType, Class subType, String message)</span><br></pre></td></tr></table></figure>
<h2 id="对象-数组-集合">对象、数组、集合</h2>
<h3 id="objectutils">ObjectUtils</h3>
<ol>
<li>获取对象的基本信息</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 获取对象的类名。参数为 null 时，返回字符串：&quot;null&quot; </span><br><span class="line">String nullSafeClassName(Object obj)</span><br><span class="line">&#x2F;&#x2F; 参数为 null 时，返回 0</span><br><span class="line">int nullSafeHashCode(Object object)</span><br><span class="line">&#x2F;&#x2F; 参数为 null 时，返回字符串：&quot;null&quot;</span><br><span class="line">String nullSafeToString(boolean[] array)</span><br><span class="line">&#x2F;&#x2F; 获取对象 HashCode（十六进制形式字符串）。参数为 null 时，返回 0 </span><br><span class="line">String getIdentityHexString(Object obj)</span><br><span class="line">&#x2F;&#x2F; 获取对象的类名和 HashCode。 参数为 null 时，返回字符串：&quot;&quot; </span><br><span class="line">String identityToString(Object obj)</span><br><span class="line">&#x2F;&#x2F; 相当于 toString()方法，但参数为 null 时，返回字符串：&quot;&quot;</span><br><span class="line">String getDisplayString(Object obj)</span><br></pre></td></tr></table></figure>
<ol>
<li>判断工具</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 判断数组是否为空</span><br><span class="line">boolean isEmpty(Object[] array)</span><br><span class="line">&#x2F;&#x2F; 判断参数对象是否是数组</span><br><span class="line">boolean isArray(Object obj)</span><br><span class="line">&#x2F;&#x2F; 判断数组中是否包含指定元素</span><br><span class="line">boolean containsElement(Object[] array, Object element)</span><br><span class="line">&#x2F;&#x2F; 相等，或同为 null时，返回 true</span><br><span class="line">boolean nullSafeEquals(Object o1, Object o2)</span><br><span class="line">&#x2F;*</span><br><span class="line">判断参数对象是否为空，判断标准为：</span><br><span class="line">    Optional: Optional.empty()</span><br><span class="line">       Array: length &#x3D;&#x3D; 0</span><br><span class="line">CharSequence: length &#x3D;&#x3D; 0</span><br><span class="line">  Collection: Collection.isEmpty()</span><br><span class="line">         Map: Map.isEmpty()</span><br><span class="line"> *&#x2F;</span><br><span class="line">boolean isEmpty(Object obj)</span><br></pre></td></tr></table></figure>
<ol>
<li>其他工具方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 向参数数组的末尾追加新元素，并返回一个新数组</span><br><span class="line">&lt;A, O extends A&gt; A[] addObjectToArray(A[] array, O obj)</span><br><span class="line">&#x2F;&#x2F; 原生基础类型数组 --&gt; 包装类数组</span><br><span class="line">Object[] toObjectArray(Object source)</span><br></pre></td></tr></table></figure>
<h3 id="stringutils">StringUtils</h3>
<ol>
<li>字符串判断工具</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 判断字符串是否为 null，或 &quot;&quot;。注意，包含空白符的字符串为非空</span><br><span class="line">boolean isEmpty(Object str)</span><br><span class="line">&#x2F;&#x2F; 判断字符串是否是以指定内容结束。忽略大小写</span><br><span class="line">boolean endsWithIgnoreCase(String str, String suffix)</span><br><span class="line">&#x2F;&#x2F; 判断字符串是否已指定内容开头。忽略大小写</span><br><span class="line">boolean startsWithIgnoreCase(String str, String prefix) </span><br><span class="line">&#x2F;&#x2F; 是否包含空白符</span><br><span class="line">boolean containsWhitespace(String str)</span><br><span class="line">&#x2F;&#x2F; 判断字符串非空且长度不为 0，即，Not Empty</span><br><span class="line">boolean hasLength(CharSequence str)</span><br><span class="line">&#x2F;&#x2F; 判断字符串是否包含实际内容，即非仅包含空白符，也就是 Not Blank</span><br><span class="line">boolean hasText(CharSequence str)</span><br><span class="line">&#x2F;&#x2F; 判断字符串指定索引处是否包含一个子串。</span><br><span class="line">boolean substringMatch(CharSequence str, int index, CharSequence substring)</span><br><span class="line">&#x2F;&#x2F; 计算一个字符串中指定子串的出现次数</span><br><span class="line">int countOccurrencesOf(String str, String sub)</span><br></pre></td></tr></table></figure>
<ol>
<li>字符串操作工具</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 查找并替换指定子串</span><br><span class="line">String replace(String inString, String oldPattern, String newPattern)</span><br><span class="line">&#x2F;&#x2F; 去除尾部的特定字符</span><br><span class="line">String trimTrailingCharacter(String str, char trailingCharacter) </span><br><span class="line">&#x2F;&#x2F; 去除头部的特定字符</span><br><span class="line">String trimLeadingCharacter(String str, char leadingCharacter)</span><br><span class="line">&#x2F;&#x2F; 去除头部的空白符</span><br><span class="line">String trimLeadingWhitespace(String str)</span><br><span class="line">&#x2F;&#x2F; 去除头部的空白符</span><br><span class="line">String trimTrailingWhitespace(String str)</span><br><span class="line">&#x2F;&#x2F; 去除头部和尾部的空白符</span><br><span class="line">String trimWhitespace(String str)</span><br><span class="line">&#x2F;&#x2F; 删除开头、结尾和中间的空白符</span><br><span class="line">String trimAllWhitespace(String str)</span><br><span class="line">&#x2F;&#x2F; 删除指定子串</span><br><span class="line">String delete(String inString, String pattern)</span><br><span class="line">&#x2F;&#x2F; 删除指定字符（可以是多个）</span><br><span class="line">String deleteAny(String inString, String charsToDelete)</span><br><span class="line">&#x2F;&#x2F; 对数组的每一项执行 trim() 方法</span><br><span class="line">String[] trimArrayElements(String[] array)</span><br><span class="line">&#x2F;&#x2F; 将 URL 字符串进行解码</span><br><span class="line">String uriDecode(String source, Charset charset)</span><br></pre></td></tr></table></figure>
<ol>
<li>路径相关工具方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 解析路径字符串，优化其中的 “..” </span><br><span class="line">String cleanPath(String path)</span><br><span class="line">&#x2F;&#x2F; 解析路径字符串，解析出文件名部分</span><br><span class="line">String getFilename(String path)</span><br><span class="line">&#x2F;&#x2F; 解析路径字符串，解析出文件后缀名</span><br><span class="line">String getFilenameExtension(String path)</span><br><span class="line">&#x2F;&#x2F; 比较两个两个字符串，判断是否是同一个路径。会自动处理路径中的 “..” </span><br><span class="line">boolean pathEquals(String path1, String path2)</span><br><span class="line">&#x2F;&#x2F; 删除文件路径名中的后缀部分</span><br><span class="line">String stripFilenameExtension(String path) </span><br><span class="line">&#x2F;&#x2F; 以 “. 作为分隔符，获取其最后一部分</span><br><span class="line">String unqualify(String qualifiedName)</span><br><span class="line">&#x2F;&#x2F; 以指定字符作为分隔符，获取其最后一部分</span><br><span class="line">String unqualify(String qualifiedName, char separator)</span><br></pre></td></tr></table></figure>
<h3 id="collectionutils">CollectionUtils</h3>
<ol>
<li>集合判断工具</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 判断 List&#x2F;Set 是否为空</span><br><span class="line">boolean isEmpty(Collection&lt;?&gt; collection)</span><br><span class="line">&#x2F;&#x2F; 判断 Map 是否为空</span><br><span class="line">boolean isEmpty(Map&lt;?,?&gt; map)</span><br><span class="line">&#x2F;&#x2F; 判断 List&#x2F;Set 中是否包含某个对象</span><br><span class="line">boolean containsInstance(Collection&lt;?&gt; collection, Object element)</span><br><span class="line">&#x2F;&#x2F; 以迭代器的方式，判断 List&#x2F;Set 中是否包含某个对象</span><br><span class="line">boolean contains(Iterator&lt;?&gt; iterator, Object element)</span><br><span class="line">&#x2F;&#x2F; 判断 List&#x2F;Set 是否包含某些对象中的任意一个</span><br><span class="line">boolean containsAny(Collection&lt;?&gt; source, Collection&lt;?&gt; candidates)</span><br><span class="line">&#x2F;&#x2F; 判断 List&#x2F;Set 中的每个元素是否唯一。即 List&#x2F;Set 中不存在重复元素</span><br><span class="line">boolean hasUniqueObject(Collection&lt;?&gt; collection)</span><br></pre></td></tr></table></figure>
<ol>
<li>集合操作工具</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 将 Array 中的元素都添加到 List&#x2F;Set 中</span><br><span class="line">&lt;E&gt; void mergeArrayIntoCollection(Object array, Collection&lt;E&gt; collection)  </span><br><span class="line">&#x2F;&#x2F; 将 Properties 中的键值对都添加到 Map 中</span><br><span class="line">&lt;K,V&gt; void mergePropertiesIntoMap(Properties props, Map&lt;K,V&gt; map)</span><br><span class="line">&#x2F;&#x2F; 返回 List 中最后一个元素</span><br><span class="line">&lt;T&gt; T lastElement(List&lt;T&gt; list)  </span><br><span class="line">&#x2F;&#x2F; 返回 Set 中最后一个元素</span><br><span class="line">&lt;T&gt; T lastElement(Set&lt;T&gt; set) </span><br><span class="line">&#x2F;&#x2F; 返回参数 candidates 中第一个存在于参数 source 中的元素</span><br><span class="line">&lt;E&gt; E findFirstMatch(Collection&lt;?&gt; source, Collection&lt;E&gt; candidates)</span><br><span class="line">&#x2F;&#x2F; 返回 List&#x2F;Set 中指定类型的元素。</span><br><span class="line">&lt;T&gt; T findValueOfType(Collection&lt;?&gt; collection, Class&lt;T&gt; type)</span><br><span class="line">&#x2F;&#x2F; 返回 List&#x2F;Set 中指定类型的元素。如果第一种类型未找到，则查找第二种类型，以此类推</span><br><span class="line">Object findValueOfType(Collection&lt;?&gt; collection, Class&lt;?&gt;[] types)</span><br><span class="line">&#x2F;&#x2F; 返回 List&#x2F;Set 中元素的类型</span><br><span class="line">Class&lt;?&gt; findCommonElementType(Collection&lt;?&gt; collection)</span><br></pre></td></tr></table></figure>
<h2 id="文件-资源-io-流">文件、资源、IO 流</h2>
<h3 id="filecopyutils">FileCopyUtils</h3>
<ol>
<li>输入</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 从文件中读入到字节数组中</span><br><span class="line">byte[] copyToByteArray(File in)</span><br><span class="line">&#x2F;&#x2F; 从输入流中读入到字节数组中</span><br><span class="line">byte[] copyToByteArray(InputStream in)</span><br><span class="line">&#x2F;&#x2F; 从输入流中读入到字符串中</span><br><span class="line">String copyToString(Reader in)</span><br></pre></td></tr></table></figure>
<ol>
<li>输出</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 从字节数组到文件</span><br><span class="line">void copy(byte[] in, File out)</span><br><span class="line">&#x2F;&#x2F; 从文件到文件</span><br><span class="line">int copy(File in, File out)</span><br><span class="line">&#x2F;&#x2F; 从字节数组到输出流</span><br><span class="line">void copy(byte[] in, OutputStream out) </span><br><span class="line">&#x2F;&#x2F; 从输入流到输出流</span><br><span class="line">int copy(InputStream in, OutputStream out) </span><br><span class="line">&#x2F;&#x2F; 从输入流到输出流</span><br><span class="line">int copy(Reader in, Writer out)</span><br><span class="line">&#x2F;&#x2F; 从字符串到输出流</span><br><span class="line">void copy(String in, Writer out)</span><br></pre></td></tr></table></figure>
<h3 id="resourceutils">ResourceUtils</h3>
<ol>
<li>从资源路径获取文件</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 判断字符串是否是一个合法的 URL 字符串。</span><br><span class="line">static boolean isUrl(String resourceLocation)</span><br><span class="line">&#x2F;&#x2F; 获取 URL</span><br><span class="line">static URL getURL(String resourceLocation) </span><br><span class="line">&#x2F;&#x2F; 获取文件（在 JAR 包内无法正常使用，需要是一个独立的文件）</span><br><span class="line">static File getFile(String resourceLocation)</span><br></pre></td></tr></table></figure>
<ol>
<li>Resource</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 文件系统资源 D:\...</span><br><span class="line">FileSystemResource</span><br><span class="line">&#x2F;&#x2F; URL 资源，如 file:&#x2F;&#x2F;... http:&#x2F;&#x2F;...</span><br><span class="line">UrlResource</span><br><span class="line">&#x2F;&#x2F; 类路径下的资源，classpth:...</span><br><span class="line">ClassPathResource</span><br><span class="line">&#x2F;&#x2F; Web 容器上下文中的资源（jar 包、war 包）</span><br><span class="line">ServletContextResource</span><br><span class="line">&#x2F;&#x2F; 判断资源是否存在</span><br><span class="line">boolean exists()</span><br><span class="line">&#x2F;&#x2F; 从资源中获得 File 对象</span><br><span class="line">File getFile()</span><br><span class="line">&#x2F;&#x2F; 从资源中获得 URI 对象</span><br><span class="line">URI getURI()</span><br><span class="line">&#x2F;&#x2F; 从资源中获得 URI 对象</span><br><span class="line">URL getURL()</span><br><span class="line">&#x2F;&#x2F; 获得资源的 InputStream</span><br><span class="line">InputStream getInputStream()</span><br><span class="line">&#x2F;&#x2F; 获得资源的描述信息</span><br><span class="line">String getDescription()</span><br></pre></td></tr></table></figure>
<h3 id="streamutils">StreamUtils</h3>
<ol>
<li>输入</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">void copy(byte[] in, OutputStream out)</span><br><span class="line">int copy(InputStream in, OutputStream out)</span><br><span class="line">void copy(String in, Charset charset, OutputStream out)</span><br><span class="line">long copyRange(InputStream in, OutputStream out, long start, long end)</span><br></pre></td></tr></table></figure>
<ol>
<li>输出</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">byte[] copyToByteArray(InputStream in)</span><br><span class="line">String copyToString(InputStream in, Charset charset)</span><br><span class="line">&#x2F;&#x2F; 舍弃输入流中的内容</span><br><span class="line">int drain(InputStream in)</span><br></pre></td></tr></table></figure>
<h2 id="反射-aop">反射、AOP</h2>
<h3 id="reflectionutils">ReflectionUtils</h3>
<ol>
<li>获取方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 在类中查找指定方法</span><br><span class="line">Method findMethod(Class&lt;?&gt; clazz, String name) </span><br><span class="line">&#x2F;&#x2F; 同上，额外提供方法参数类型作查找条件</span><br><span class="line">Method findMethod(Class&lt;?&gt; clazz, String name, Class&lt;?&gt;... paramTypes) </span><br><span class="line">&#x2F;&#x2F; 获得类中所有方法，包括继承而来的</span><br><span class="line">Method[] getAllDeclaredMethods(Class&lt;?&gt; leafClass) </span><br><span class="line">&#x2F;&#x2F; 在类中查找指定构造方法</span><br><span class="line">Constructor&lt;T&gt; accessibleConstructor(Class&lt;T&gt; clazz, Class&lt;?&gt;... parameterTypes) </span><br><span class="line">&#x2F;&#x2F; 是否是 equals() 方法</span><br><span class="line">boolean isEqualsMethod(Method method) </span><br><span class="line">&#x2F;&#x2F; 是否是 hashCode() 方法 </span><br><span class="line">boolean isHashCodeMethod(Method method) </span><br><span class="line">&#x2F;&#x2F; 是否是 toString() 方法</span><br><span class="line">boolean isToStringMethod(Method method) </span><br><span class="line">&#x2F;&#x2F; 是否是从 Object 类继承而来的方法</span><br><span class="line">boolean isObjectMethod(Method method) </span><br><span class="line">&#x2F;&#x2F; 检查一个方法是否声明抛出指定异常</span><br><span class="line">boolean declaresException(Method method, Class&lt;?&gt; exceptionType)</span><br></pre></td></tr></table></figure>
<ol>
<li>执行方法</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 执行方法</span><br><span class="line">Object invokeMethod(Method method, Object target)  </span><br><span class="line">&#x2F;&#x2F; 同上，提供方法参数</span><br><span class="line">Object invokeMethod(Method method, Object target, Object... args) </span><br><span class="line">&#x2F;&#x2F; 取消 Java 权限检查。以便后续执行该私有方法</span><br><span class="line">void makeAccessible(Method method) </span><br><span class="line">&#x2F;&#x2F; 取消 Java 权限检查。以便后续执行私有构造方法</span><br><span class="line">void makeAccessible(Constructor&lt;?&gt; ctor)</span><br></pre></td></tr></table></figure>
<ol>
<li>获取字段</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 在类中查找指定属性</span><br><span class="line">Field findField(Class&lt;?&gt; clazz, String name) </span><br><span class="line">&#x2F;&#x2F; 同上，多提供了属性的类型</span><br><span class="line">Field findField(Class&lt;?&gt; clazz, String name, Class&lt;?&gt; type) </span><br><span class="line">&#x2F;&#x2F; 是否为一个 &quot;public static final&quot; 属性</span><br><span class="line">boolean isPublicStaticFinal(Field field)</span><br></pre></td></tr></table></figure>
<ol>
<li>设置字段</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 获取 target 对象的 field 属性值</span><br><span class="line">Object getField(Field field, Object target) </span><br><span class="line">&#x2F;&#x2F; 设置 target 对象的 field 属性值，值为 value</span><br><span class="line">void setField(Field field, Object target, Object value) </span><br><span class="line">&#x2F;&#x2F; 同类对象属性对等赋值</span><br><span class="line">void shallowCopyFieldState(Object src, Object dest)</span><br><span class="line">&#x2F;&#x2F; 取消 Java 的权限控制检查。以便后续读写该私有属性</span><br><span class="line">void makeAccessible(Field field) </span><br><span class="line">&#x2F;&#x2F; 对类的每个属性执行 callback</span><br><span class="line">void doWithFields(Class&lt;?&gt; clazz, ReflectionUtils.FieldCallback fc) </span><br><span class="line">&#x2F;&#x2F; 同上，多了个属性过滤功能。</span><br><span class="line">void doWithFields(Class&lt;?&gt; clazz, ReflectionUtils.FieldCallback fc, </span><br><span class="line">                  ReflectionUtils.FieldFilter ff) </span><br><span class="line">&#x2F;&#x2F; 同上，但不包括继承而来的属性</span><br><span class="line">void doWithLocalFields(Class&lt;?&gt; clazz, ReflectionUtils.FieldCallback fc)</span><br></pre></td></tr></table></figure>
<h3 id="aoputils">AopUtils</h3>
<ol>
<li>判断代理类型</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 判断是不是 Spring 代理对象</span><br><span class="line">boolean isAopProxy()</span><br><span class="line">&#x2F;&#x2F; 判断是不是 jdk 动态代理对象</span><br><span class="line">isJdkDynamicProxy()</span><br><span class="line">&#x2F;&#x2F; 判断是不是 CGLIB 代理对象</span><br><span class="line">boolean isCglibProxy()</span><br></pre></td></tr></table></figure>
<ol>
<li>获取被代理对象的 class</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&#x2F;&#x2F; 获取被代理的目标 class</span><br><span class="line">Class&lt;?&gt; getTargetClass()</span><br></pre></td></tr></table></figure>
<h3 id="aopcontext">AopContext</h3>
<ol>
<li>获取当前对象的代理对象</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Object currentProxy()</span><br></pre></td></tr></table></figure>

                

                <hr>
                <!-- Pager -->
                <ul class="pager">
                    
                        <li class="previous">
                            <a href="/Nginx配置/2019-03-15/" data-toggle="tooltip" data-placement="top" title="Nginx 常用配置清单">&larr; Previous Post</a>
                        </li>
                    
                    
                        <li class="next">
                            <a href="/Git命令/2019-03-07/" data-toggle="tooltip" data-placement="top" title="Git命令总结">Next Post &rarr;</a>
                        </li>
                    
                </ul>

                <br>

                <!--打赏-->
                
                <!--打赏-->

                <br>
                <!--分享-->
                
                    <div class="social-share"  data-wechat-qrcode-helper="" align="center"></div>
                    <!--  css & js -->
                    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/css/share.min.css">
                    <script src="https://cdnjs.cloudflare.com/ajax/libs/social-share.js/1.0.16/js/social-share.min.js"></script>
                
                <!--分享-->
                <br>                       
                
                <!-- require APlayer -->
                

                <!-- duoshuo Share start -->
                
                <!-- 多说 Share end-->

                <!-- 多说评论框 start -->
                
                <!-- 多说评论框 end -->

                <!-- disqus comment start -->
                
                    <div class="comment">
                        <div id="disqus_thread" class="disqus-thread"></div>
                    </div>
                
                <!-- disqus comment end -->

                

            </div>
            
            <!-- Tabe of Content -->
            <!-- Table of Contents -->

  
    <style>
      span.toc-nav-number{
        display: none
      }
    </style>
  
    
      <aside id="sidebar">
        <div id="toc" class="toc-article">
        <strong class="toc-title">Contents</strong>
        
          <ol class="toc-nav"><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#断言"><span class="toc-nav-number">1.</span> <span class="toc-nav-text">断言</span></a></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#对象-数组-集合"><span class="toc-nav-number">2.</span> <span class="toc-nav-text">对象、数组、集合</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#objectutils"><span class="toc-nav-number">2.1.</span> <span class="toc-nav-text">ObjectUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#stringutils"><span class="toc-nav-number">2.2.</span> <span class="toc-nav-text">StringUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#collectionutils"><span class="toc-nav-number">2.3.</span> <span class="toc-nav-text">CollectionUtils</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#文件-资源-io-流"><span class="toc-nav-number">3.</span> <span class="toc-nav-text">文件、资源、IO 流</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#filecopyutils"><span class="toc-nav-number">3.1.</span> <span class="toc-nav-text">FileCopyUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#resourceutils"><span class="toc-nav-number">3.2.</span> <span class="toc-nav-text">ResourceUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#streamutils"><span class="toc-nav-number">3.3.</span> <span class="toc-nav-text">StreamUtils</span></a></li></ol></li><li class="toc-nav-item toc-nav-level-2"><a class="toc-nav-link" href="#反射-aop"><span class="toc-nav-number">4.</span> <span class="toc-nav-text">反射、AOP</span></a><ol class="toc-nav-child"><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#reflectionutils"><span class="toc-nav-number">4.1.</span> <span class="toc-nav-text">ReflectionUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#aoputils"><span class="toc-nav-number">4.2.</span> <span class="toc-nav-text">AopUtils</span></a></li><li class="toc-nav-item toc-nav-level-3"><a class="toc-nav-link" href="#aopcontext"><span class="toc-nav-number">4.3.</span> <span class="toc-nav-text">AopContext</span></a></li></ol></li></ol>
        
        </div>
      </aside>
    

                
            <!-- Sidebar Container -->
            <div class="
                col-lg-8 col-lg-offset-2
                col-md-10 col-md-offset-1
                sidebar-container">

                <!-- Featured Tags -->
                
                <section>
                    <!-- no hr -->
                    <h5><a href="/tags/">FEATURED TAGS</a></h5>
                    <div class="tags">
                       
                          <a class="tag" href="/tags/#Git" title="Git">Git</a>
                        
                    </div>
                </section>
                

                <!-- Friends Blog -->
                
            </div>
        </div>
    </div>
</article>




<!-- disqus embedded js code start (one page only need to embed once) -->
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES * * */
    var disqus_shortname = "your-disqus-ID";
    var disqus_identifier = "http://www.wangxiaohuan.com/Git%E5%91%BD%E4%BB%A4/2019-03-10/";
    var disqus_url = "http://www.wangxiaohuan.com/Git%E5%91%BD%E4%BB%A4/2019-03-10/";

    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>
<!-- disqus embedded js code start end -->





<!-- async load function -->
<script>
    function async(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>
<!-- anchor-js, Doc:http://bryanbraun.github.io/anchorjs/ -->
<script>
    async("https://cdn.bootcss.com/anchor-js/1.1.1/anchor.min.js",function(){
        anchors.options = {
          visible: 'hover',
          placement: 'left',
          icon: 'ℬ'
        };
        anchors.add().remove('.intro-header h1').remove('.subheading').remove('.sidebar-container h5');
    })
</script>
<style>
    /* place left on bigger screen */
    @media all and (min-width: 800px) {
        .anchorjs-link{
            position: absolute;
            left: -0.75em;
            font-size: 1.1em;
            margin-top : -0.1em;
        }
    }
</style>



    <!-- Footer -->
    <!-- Footer -->
<footer>
    <div class="container">
        <div class="row">
            <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
                <ul class="list-inline text-center">
                
                
                    <li>
                        <a target="_blank" href="https://twitter.com/work_wxh">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                
                

                
                    <li>
                        <a target="_blank" href="http://weibo.com/2742646782">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-weibo fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                
                    <li>
                        <a target="_blank" href="https://www.facebook.com/wxh.work">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                
                    <li>
                        <a target="_blank"  href="https://github.com/xiaohuanwang">
                            <span class="fa-stack fa-lg">
                                <i class="fa fa-circle fa-stack-2x"></i>
                                <i class="fa fa-github fa-stack-1x fa-inverse"></i>
                            </span>
                        </a>
                    </li>
                

                

                </ul>
                <p class="copyright text-muted">
                    Copyright &copy; 吃素的左撇子 2022 
                    <br>
                    Theme by <a href="http://beantech.org" target="_blank" rel="noopener">BeanTech</a> 
                    <span style="display: inline-block; margin: 0 5px;">
                        <i class="fa fa-heart"></i>
                    </span> 
                    re-Ported by <a href="http://www.wangxiaohuan.com">吃素的左撇子</a> | 
                    <iframe
                        style="margin-left: 2px; margin-bottom:-5px;"
                        frameborder="0" scrolling="0" width="91px" height="20px"
                        src="https://ghbtns.com/github-btn.html?user=xiaohuanwang&repo=hexo-theme-xiaohuanwang&type=star&count=true" >
                    </iframe>
                </p>
            </div>
        </div>
    </div>
</footer>

<!-- jQuery -->

<script src="/js/jquery.min.js"></script>


<!-- Bootstrap Core JavaScript -->

<script src="/js/bootstrap.min.js"></script>


<!-- Custom Theme JavaScript -->

<script src="/js/hux-blog.min.js"></script>



<!-- async load function -->
<script>
    function async(u, c) {
      var d = document, t = 'script',
          o = d.createElement(t),
          s = d.getElementsByTagName(t)[0];
      o.src = u;
      if (c) { o.addEventListener('load', function (e) { c(null, e); }, false); }
      s.parentNode.insertBefore(o, s);
    }
</script>

<!-- 
     Because of the native support for backtick-style fenced code blocks 
     right within the Markdown is landed in Github Pages, 
     From V1.6, There is no need for Highlight.js, 
     so Huxblog drops it officially.

     - https://github.com/blog/2100-github-pages-now-faster-and-simpler-with-jekyll-3-0  
     - https://help.github.com/articles/creating-and-highlighting-code-blocks/    
-->
<!--
    <script>
        async("http://cdn.bootcss.com/highlight.js/8.6/highlight.min.js", function(){
            hljs.initHighlightingOnLoad();
        })
    </script>
    <link href="http://cdn.bootcss.com/highlight.js/8.6/styles/github.min.css" rel="stylesheet">
-->


<!-- jquery.tagcloud.js -->
<script>
    // only load tagcloud.js in tag.html
    if($('#tag_cloud').length !== 0){
        async("http://www.wangxiaohuan.com/js/jquery.tagcloud.js",function(){
            $.fn.tagcloud.defaults = {
                //size: {start: 1, end: 1, unit: 'em'},
                color: {start: '#bbbbee', end: '#0085a1'},
            };
            $('#tag_cloud a').tagcloud();
        })
    }
</script>

<!--fastClick.js -->
<script>
    async("https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js", function(){
        var $nav = document.querySelector("nav");
        if($nav) FastClick.attach($nav);
    })
</script>


<!-- Google Analytics -->


<script>
    // dynamic User by Hux
    var _gaId = 'UA-XXXXXXXX-X';
    var _gaDomain = 'yoursite';

    // Originial
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', _gaId, _gaDomain);
    ga('send', 'pageview');
</script>




<!-- Baidu Tongji -->

<script>
    // dynamic User by Hux
    var _baId = 'xxx';

    // Originial
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?" + _baId;
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
</script>






	<a id="rocket" href="#top" class=""></a>
	<script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
    <script type="text/javascript" src="/js/toc.js?v=1.0.0" async=""></script>
<!-- Image to hack wechat -->
<img src="http://www.wangxiaohuan.com/img/icon_wechat.png" width="0" height="0" />
<!-- Migrate from head to bottom, no longer block render and still work -->

</body>

</html>
